package com.skywolf.chem.match.controller;


import com.skywolf.chem.common.sysconfig.response.RespData;
import com.skywolf.chem.match.params.param.ApplyDeletedUserParam;
import com.skywolf.chem.match.params.param.ApplyUserInfoParam;
import com.skywolf.chem.match.params.param.ApplyUserListParam;
import com.skywolf.chem.match.service.IApplyUserRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 报名管理
 *
 * @author sj
 * @since 2021-09-26
 */
@AllArgsConstructor
@RestController
@RequestMapping("/match/apply")
@Api(value = "赛事：报名信息API", tags = {"赛事：报名信息API"})
public class ApplyUserRecordController extends BaseController {

    private final IApplyUserRecordService recordService;

    @ApiOperation(value = "添加报名人/验证报名人信息", notes = "添加报名人/验证报名人信息")
    @PostMapping("/go/verify")
    public RespData insertAndVerifyApplyUser(@RequestBody @Validated ApplyUserInfoParam param) throws Exception {
        recordService.insertAndVerifyApplyUser(getUserId(), param);
        return RespData.success();
    }

    @ApiOperation(value = "修改报名人信息", notes = "修改报名人信息")
    @PostMapping("/update/verify")
    public RespData updateApplyUser(@RequestBody @Validated ApplyUserInfoParam param) throws Exception {
        recordService.updateApplyUser(getUserId(), param);
        return RespData.success();
    }

    @ApiOperation(value = "删除报名人", notes = "删除报名人")
    @PostMapping("/deleted/")
    public RespData deletedApplyUser(@RequestBody @Validated ApplyDeletedUserParam param) throws Exception {
        recordService.deletedApplyUser(getUserId(),param);
        return RespData.success();
    }

    @ApiOperation(value = "获取报名人列表", notes = "获取报名人列表")
    @PostMapping("/list/")
    public RespData<List<ApplyUserInfoParam>> getApplyUserList(@RequestBody @Validated ApplyUserListParam param){
        List<ApplyUserInfoParam> infoList=recordService.getApplyUserList(getUserId(),param);
        return RespData.success(infoList);
    }

    @ApiOperation(value = "清空报名人列表", notes = "清空报名人列表")
    @PostMapping("/clear/")
    public RespData clearApplyUserList(@RequestBody @Validated ApplyUserListParam param){
        recordService.clearApplyUserList(getUserId(),param);
        return RespData.success();
    }



}
